package com.quantanetwork.esm.port;

import java.io.IOException;

import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.GetMethod;

/**
* Company: QuantaNetwork BeiJing Ltd
* Author : 张彦龙
* DateTime: Nov 25, 2008  4:31:17 PM
*/
public class HttpIndentifyMethod extends IdentifyMethod
{
	@Override
	public Portinfo indentify(String server, int port, String message, String type, int timeOut)
	{
		Portinfo portInfoBean = null;
		HttpClient client = new HttpClient();
		GetMethod method = new GetMethod("http://" + server + ":" + port);
		try
		{
			client.executeMethod(method);
			Header header = method.getResponseHeader("Server");
			if (header != null)
			{
				portInfoBean = new Portinfo();
				portInfoBean.setDesc("HTTP Server:" + header.getValue());
			}
		}
		catch (HttpException e)
		{
		}
		catch (IOException e)
		{
		}
		return portInfoBean;
	}
}
